﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$makhoa_old = $_GET["makhoa"];
$makhoa_new = $_POST["txtMAK"];
$tenkhoa = $_POST["txtTenK"];

// Kiem tra ma khoa
$queryMAK = "select * from khoa where MA_KHOA = '$makhoa_new' and MA_KHOA <> '$makhoa_old'";
$resultMAK = mysql_query($queryMAK, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMAK);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=editcnk&makhoa=$makhoa_old&info=dupmak");
}
else
{
	// Sua thong tin khoa
	$queryUpdK = "update khoa set MA_KHOA = '$makhoa_new', TEN_KHOA = '$tenkhoa' where MA_KHOA = '$makhoa_old'";
	mysql_query($queryUpdK, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=editcnksucc");
}

?>